package Meta

import "db2s/global"

func (ma Meta) triggerEr(drive string) (ter TriggerEr, err error) {
	if ter, err = NewMetaTrigger(drive,ma.Parameter); err != nil {
		return
	}
	return
}
func (ma Meta) triggerName() (meta any, err error) {
	var ter TriggerEr
	var res []any
	for k, v := range ma.Drive {
		if ter, err = ma.triggerEr(v); err != nil {
			return
		}
		var result global.Return
		if result, err = ter.Name(ma.Parameter.Con[k]); err != nil {
			return
		}
		res = append(res, result.Result)
	}
	meta = joinResult(ma.Join, res)
	return
}
func (ma Meta) triggerExistence() (meta any, err error) {
	var ter TriggerEr
	var res []any
	for k, v := range ma.Drive {
		if ter, err = ma.triggerEr(v); err != nil {
			return
		}
		var result global.Return
		if result, err = ter.Existence(ma.Parameter.Con[k]); err != nil {
			return
		}
		res = append(res, result.Result)
	}
	meta = joinResult(ma.Join, res)
	return
}

